new Vue({
    el: "#content",
    data: {
        makeUser: [],
        meeting: {},
        userList: [],
        deptList: []
    },
    methods: {
        addMeeting: function () {
            this.meeting.startTime=$("#startTime").val();
            this.meeting.endTime=$("#endTime").val();
            let str = "";
            for (let i = 0; i < this.makeUser.length; i++) {
                if (i == this.makeUser.length - 1) {
                    str += this.makeUser[i] + "";
                } else {
                    str += this.makeUser[i] + ",";
                }
            }

            this.meeting.makeUser = str;
            axios({
                method: 'post',
                url: "/meeting/addMeeting",
                data: this.meeting
            }).then(res => {
                layer.msg(res.data.message);
                if (res.data.flag) {
                    setInterval(() => {
                        location.href = "/html/meeting.html";
                    }, 1000);
                }
            });
        },
        findAllDept: function () {
            axios({
                method: 'get',
                url: '/dept'
            }).then(res => {
                if (res.data.flag) {
                    this.deptList = res.data.data;
                } else {
                    layer.msg(res.data.message);
                }
            });
        },
        findDeptUser: function () {
            axios({
                method: 'get',
                url: `/user/findDeptUser/${this.meeting.deptId}`
            }).then(res => {
                if (res.data.flag) {
                    this.userList = res.data.data;
                } else {
                    layer.msg(res.data.message);
                }
            }).finally((res) => {
                // 重新刷新select下拉框
                $('#users').selectpicker('refresh');
            });
        }
    },
    created: function () {
        this.findAllDept();
    }
})